package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.AuditFlowDetail;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/mapper/AuditFlowDetailMapper.class */
public interface AuditFlowDetailMapper {
    @Results(id = "map", value = {@Result(property = "flowNo", column = "flow_no"),
            @Result(property = "auditTime", column = "audit_time"),
            @Result(property = "auditStatus", column = "audit_status"),
            @Result(property = "signatureUrl", column = "signature_url")})
    @Select({"select *  from  audit_flow_detail where id = #{id}"})
    AuditFlowDetail queryById(Integer num);

    @ResultMap({"map"})
    @Select({"<script>" +
            "select afd.*,u.name as reviewerName,r.role_name as roleName " +
            "from audit_flow_detail afd " +
            "left join user u on afd.reviewer = u.id " +
            "left join role r on u.role_id = r.id " +
            "<where> <if test='flowNo != null and flowNo.length &gt; 0'>flow_no=#{flowNo} </if>" +
            "<if test='reviewer != null '>reviewer=#{reviewer} </if>" +
            "<if test='auditStatus != null and auditStatus.length &gt; 0'>audit_status=#{auditStatus} </if>" +
            "</where> order by afd.id asc" +
            "</script>"})
    List<AuditFlowDetail> queryAll(AuditFlowDetail auditFlowDetail);

    @Insert({"insert into audit_flow_detail(flow_no,reviewer,remark,audit_time,audit_status,signature_url)values(#{flowNo},#{reviewer},#{remark},#{auditTime},#{auditStatus},#{signatureUrl})"})
    int insert(AuditFlowDetail auditFlowDetail);

    @Update({"<script>update audit_flow_detail <set><if test='flowNo != null and flowNo.length &gt; 0'> flow_no=#{flowNo},</if><if test='flowNo != null and flowNo.length &gt; 0'> flow_no=#{flowNo},</if><if test='reviewer != null '> reviewer=#{reviewer},</if><if test='remark != null and remark.length &gt; 0'> remark=#{remark},</if><if test='auditTime != null and auditTime.length &gt; 0'> audit_time=#{auditTime},</if><if test='auditStatus != null '> audit_status=#{auditStatus},</if></set>where id = #{id}</script>"})
    int update(AuditFlowDetail auditFlowDetail);

    @Delete({"delete from audit_flow_detail where id = #{id}"})
    int deleteById(Integer num);

    @Delete({"delete from audit_flow_detail where flow_no = #{flowNo}"})
    int deleteByFlowNo(String str);

    @Update({"<script>update audit_flow_detail <set><if test='auditStatus != null '> audit_status=#{auditStatus},</if><if test='auditTime != null and auditTime.length &gt; 0'> audit_time=#{auditTime},</if><if test='remark != null and remark.length &gt; 0'> remark=#{remark},</if><if test='signatureUrl != null and signatureUrl.length &gt; 0'> signature_url=#{signatureUrl}</if></set>where flow_no = #{flowNo} and reviewer = #{reviewer} and audit_status != 0 </script>"})
    int updateAuditStatus(AuditFlowDetail auditFlowDetail);

    @Delete({"delete from audit_flow_detail where flow_no = #{flowNo} and id > (select id from (select id from audit_flow_detail where flow_no = #{flowNo} and audit_status = #{auditStatus}  order by id desc limit 1 ) as a)"})
    int deleteByFlowNoAndId(@Param("flowNo") String str, @Param("auditStatus") Integer num);
}